require 'migration_helpers'

class CreateSchools < ActiveRecord::Migration
  extend MigrationHelper::ForeignKeys
  
  def self.up
    create_table :schools do |t|
      t.column :address_id, :integer
      t.column :code, :string
      t.column :name, :string
      t.column :url, :string
      t.column :created_at, :datetime
      t.column :udpated_at, :datetime
    end
    
    add_foreign_key(:schools, :address_id, :addresses)
    
    School.create(:name => 'Costa Mesa HS', :code => 'CMHS')
    School.create(:name => 'Fountain Valley HS', :code => 'FVHS')
    School.create(:name => 'Mater Dei HS', :code => 'MDHS')
    School.create(:name => 'Bolsa Grande HS', :code => 'BGHS')
    School.create(:name => 'University HS', :code => 'UHS')
    School.create(:name => 'Edison HS', :code => 'EHS')
  end

  def self.down
    drop_table :schools
  end
end
